package com.gjx.springboot.api.controller;

import com.gjx.springboot.domain.entity.Employees;
import com.gjx.springboot.app.service.EmployeesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class EmployeesController {
    @Autowired
    EmployeesService employeesService;
    @RequestMapping("/getdepartmentemployees")
    @ResponseBody
    public List<Employees> getDepartMentEmployees(){
        List<Employees> employeesDepartMent = employeesService.getEmployeesDepartMent();
        return employeesDepartMent;
    }

    //插入一条数据
    @RequestMapping(value = "/insertoneemployees")
    @ResponseBody
    public Boolean insertOneEmployees(@RequestBody Employees employees) {
        Boolean aBoolean = employeesService.insertOneEmployees(employees);
        return aBoolean;
    }

    @RequestMapping("/deleteoneemployees")
    @ResponseBody
    public Boolean deleteOneEmplpyees(Integer employeeId) {
        Boolean aBoolean = employeesService.deleteOneEmployees(employeeId);
        return aBoolean;
    }
    @RequestMapping("/updateoneemployees")
    @ResponseBody
    public Boolean updateOneEmployees(@RequestBody Employees employees){
        Boolean aBoolean = employeesService.updateOneEmployees(employees);
        return aBoolean;
    }

    //批量插入
    @RequestMapping("/insertmoreemployees")
    @ResponseBody
    public Integer insertMoreEmployees(@RequestBody List<Employees> employeesList){
        Integer integer = employeesService.insertMoreEmployees(employeesList);
        return integer;
    }
}
